package edu.umuc.cmsc495_final_project;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.util.logging.Level;

public class importDB extends application {

	/**
	 * 
	 */
	private static final long serialVersionUID = -966495107769950903L;

	public importDB(String sFileName) {
		generateDBFile(sFileName);
	}

	private void generateDBFile(String sFileName) {

		// open previous db
		try {
			// use buffering
			FileInputStream file = new FileInputStream(sFileName);
			InputStream buffer = new BufferedInputStream(file);
			ObjectInputStream input = new ObjectInputStream(buffer);
			try {
				Object obj = input.readObject();

				if (obj instanceof DataBase)
					db = (DataBase) obj;

				System.out.println("Object opened is: " + db);

			} finally {
				input.close();
			}
		} catch (ClassNotFoundException ex) {
			System.err.printf(Level.SEVERE + " Cannot perform input. Class not found.", ex);
		} catch (IOException ex) {
			System.err.println("Cannot perform input." + ex);
		}
	}
}